<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			#div1{
				width:100px;
				height:100px;
				background: red;
				position:absolute;
				top:50px;
				left:50px;
			}
		</style>
		<script>
			window.onload = function(){
				var oDiv = document.getElementById("div1");
				
//				function move(obj){
//					var timer = setInterval(function(){
//						var oldLeft = obj.offsetLeft;
//						var newLeft = oldLeft + 10;
//						if(newLeft>700){
//							clearInterval(timer);
//							newLeft = 700;
//						}
//						obj.style.left = newLeft + 'px';
//					},1000/60);
//				}
				
				
				function move(obj,speed,target){
					var timer = setInterval(function(){
						var oldLeft = obj.offsetLeft;
						var newLeft = oldLeft + speed;
						if(newLeft>target){
							clearInterval(timer);
							newLeft = target;
						}
						obj.style.left = newLeft + 'px';
					},1000/60);
				}
				
				move(oDiv,10,500);
			}
			
		</script>
	</head>
	<body>
		<div id="div1">
			111
		</div>
	</body>
</html>
